Skip to content

Fold/visit tweaks#156130

Open
nnethercote wants to merge 2 commits intorust-lang:mainfrom
nnethercote:fold-visit-tweaks
Open

Fold/visit tweaks#156130
nnethercote wants to merge 2 commits intorust-lang:mainfrom
nnethercote:fold-visit-tweaks

Conversation

@nnethercote
Copy link
Copy Markdown
Contributor

Details in individual commits.

r? @WaffleLapkin

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 4, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 4, 2026

WaffleLapkin is not on the review rotation at the moment.
They may take a while to respond.

Copy link
Copy Markdown
Member

@WaffleLapkin WaffleLapkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me with nits

Unrelated, you've been assigning me semi-regularly recently, might I ask why? (I don't mind reviewing your PRs, just curious)

View changes since this review

Comment thread compiler/rustc_type_ir/src/visit.rs Outdated
Comment thread compiler/rustc_type_ir/src/flags.rs
fn has_type_flags(&self, flags: TypeFlags) -> bool {
let res =
self.visit_with(&mut HasTypeFlagsVisitor { flags }) == ControlFlow::Break(FoundFlags);
res
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo comparing with ControlFlow::Break(FoundFlags) is clearer, because it asserts that Break contains FoundFlags

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though FoundFlags is a unit type?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that has_vars_bound_at_or_above uses .is_break(). I was fixing the inconsistency and .is_break() seemed nicer.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though FoundFlags is a unit type?

Yes; With == ControlFlow::Break(FoundFlags) it's clearer why Break means that the flags have been found, without looking at surrounding code / type returned by visit_with.

But ultimately this is such a small nitpick...

@nnethercote
Copy link
Copy Markdown
Contributor Author

you've been assigning me semi-regularly recently, might I ask why?

I always choose a reviewer rather than letting bors randomly assign. Usually I choose somebody who knows the relevant part of the code well. Or if it's an easier PR that doesn't require specific expertise I just pick someone who I haven't picked for a while.

- Remove comment about blanket implementation of `FallibleTypeFolder` --
  it does not exist. (It probably used to.)
- Fix some incorrect name references.
- Fix minor grammatical errors.
- Fix stale comment on `visit_region` -- it was a no-op once, but no
  longer.

LLM disclosure: Claude Code identified these problems with comments when
I asked it to review `fold.rs` and `visit.rs`. I verified the
correctness of the problems and made the changes by hand.
@nnethercote nnethercote force-pushed the fold-visit-tweaks branch from fd068fd to dd4ce84 Compare May 5, 2026 00:23
@nnethercote
Copy link
Copy Markdown
Contributor Author

I addressed two of the three comments, and left the is_break unchanged for now pending further discussion.

Comment thread compiler/rustc_type_ir/src/fold.rs Outdated
fn has_type_flags(&self, flags: TypeFlags) -> bool {
let res =
self.visit_with(&mut HasTypeFlagsVisitor { flags }) == ControlFlow::Break(FoundFlags);
res
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though FoundFlags is a unit type?

Yes; With == ControlFlow::Break(FoundFlags) it's clearer why Break means that the flags have been found, without looking at surrounding code / type returned by visit_with.

But ultimately this is such a small nitpick...

- Introduce `HAS_REGIONS`/`has_regions`, which is true if any regions
  are present.
- Add `fold_clauses` to `Shifter` and `RegionFolder` for consistency.
- Simplify `has_type_flags`.
- Remove unnecessary local variables in `HasTypeFlagsVisitor` methods.
- Use `|=` operator in one place.
- Avoid `is_break` in one place for consistency with nearby code.

LLM disclosure: Claude Code suggested these changes when I asked it to
review `fold.rs` and `visit.rs`. I verified the correctness of the
suggestions and made the changes by hand.
@nnethercote nnethercote force-pushed the fold-visit-tweaks branch from dd4ce84 to 803c7ba Compare May 6, 2026 03:26
@nnethercote
Copy link
Copy Markdown
Contributor Author

I addressed the latest two comments.

@WaffleLapkin
Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 6, 2026

📌 Commit 803c7ba has been approved by WaffleLapkin

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 6, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request May 6, 2026
…affleLapkin

Fold/visit tweaks

Details in individual commits.

r? @WaffleLapkin
rust-bors Bot pushed a commit that referenced this pull request May 6, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #146273 (lint ImproperCTypes: refactor linting architecture (part 2))
 - #156173 (Fewer global node_id_to_def_id lookups)
 - #155961 (Deny warnings in the test for crates that are available on stable)
 - #156130 (Fold/visit tweaks)
 - #156131 (Metadata macro/query cleanups)
 - #156141 (Resolve some cases of #132279 by using the right typing mode in the next solver)
 - #156202 (llvm: Use correct type for splat mask)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request May 6, 2026
…affleLapkin

Fold/visit tweaks

Details in individual commits.

r? @WaffleLapkin
rust-bors Bot pushed a commit that referenced this pull request May 6, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #146273 (lint ImproperCTypes: refactor linting architecture (part 2))
 - #149509 (Lint unused pub items in binary crates)
 - #156173 (Fewer global node_id_to_def_id lookups)
 - #155961 (Deny warnings in the test for crates that are available on stable)
 - #156130 (Fold/visit tweaks)
 - #156131 (Metadata macro/query cleanups)
 - #156202 (llvm: Use correct type for splat mask)

Failed merges:

 - #156236 (resolve: Remove `MacroData`)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request May 6, 2026
…affleLapkin

Fold/visit tweaks

Details in individual commits.

r? @WaffleLapkin
rust-bors Bot pushed a commit that referenced this pull request May 6, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #156061 (Support `-Cpanic=unwind` on WASI targets)
 - #146273 (lint ImproperCTypes: refactor linting architecture (part 2))
 - #149509 (Lint unused pub items in binary crates)
 - #156173 (Fewer global node_id_to_def_id lookups)
 - #155961 (Deny warnings in the test for crates that are available on stable)
 - #155981 (Use special DefIds for aliases)
 - #156130 (Fold/visit tweaks)
 - #156131 (Metadata macro/query cleanups)
 - #156202 (llvm: Use correct type for splat mask)

Failed merges:

 - #156236 (resolve: Remove `MacroData`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants